package com.lagou.controller;

import com.lagou.domain.Employee;
import com.lagou.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;


@Controller
@RequestMapping("/employee")
public class EmployeeController {

    @Autowired
    private EmpService empService;

    @RequestMapping("/findAll")
    public String findAll(Model model){

        model.addAttribute("list",empService.findAll());
        return "list";
    }

    @RequestMapping("/add")
    public String add(Employee employee){

        empService.add(employee);
        return "redirect:/employee/findAll";
    }
}
